using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Xoohoo.Repositories.SqlServerEF.Entities;

namespace Xoohoo.Repositories.SqlServerEF.Mapping
{
	public class PermissionMap : EntityTypeConfiguration<Permission>
	{
		public PermissionMap()
		{
			// Primary Key
			this.HasKey(t => t.PermissionID);

            // Properties
            this.Property(t => t.ModuleName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.PermissionName)
                .IsRequired()
                .HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("Permission");
			this.Property(t => t.ParentID).HasColumnName("ParentID");
			this.Property(t => t.PermissionID).HasColumnName("PermissionID");
			this.Property(t => t.ModuleName).HasColumnName("ModuleName");
			this.Property(t => t.PermissionName).HasColumnName("PermissionName");
			this.Property(t => t.PermissionLevel).HasColumnName("PermissionLevel");
			this.Property(t => t.DisplayOrder).HasColumnName("DisplayOrder");
		}
	}
}

